home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / news-text.scm < prev    next >
Encoding:
Text File  |  2005-06-30  |  3.2 KB  |  84 lines

  1. ; Newsprint text
  2. ; Copyright (c) 1998 Austin Donnelly <austin@greenend.org.uk>
  3. ;
  4. ;
  5. ; Based on alien glow code from Adrian Likins
  6. ; This program is free software; you can redistribute it and/or modify
  7. ; it under the terms of the GNU General Public License as published by
  8. ; the Free Software Foundation; either version 2 of the License, or
  9. ; (at your option) any later version.
  10. ; This program is distributed in the hope that it will be useful,
  11. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ; GNU General Public License for more details.
  14. ; You should have received a copy of the GNU General Public License
  15. ; along with this program; if not, write to the Free Software
  16. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.  
  19. (define (script-fu-newsprint-text string font font-size cell-size density blur-radius text-color bg-color)
  20.   (let* ((text-ext (gimp-text-get-extents-fontname string font-size PIXELS font))
  21.      (width (+ (car text-ext) 20 blur-radius))
  22.      (height  (+ (nth 1 text-ext) 20 blur-radius))
  23.      (img (car (gimp-image-new width height RGB)))
  24.      (bg-layer (car (gimp-layer-new img width height  RGB-IMAGE "Background" 100 NORMAL-MODE)))
  25.      (text-layer (car (gimp-layer-new img width height  RGBA-IMAGE "Text layer" 100 NORMAL-MODE)))
  26.      (text-mask 0)
  27.      (grey (/ (* density 255) 100)))
  28.  
  29.     (gimp-context-push)
  30.  
  31.     (gimp-image-undo-disable img)
  32.     (gimp-image-add-layer img bg-layer 1)
  33.     (gimp-image-add-layer img text-layer -1)
  34.  
  35.     (gimp-context-set-background bg-color)
  36.     (gimp-edit-clear bg-layer)
  37.     (gimp-edit-clear text-layer)
  38.  
  39.     (gimp-context-set-foreground text-color)
  40.     (gimp-floating-sel-anchor (car (gimp-text-fontname img text-layer (/ (+ 20 blur-radius) 2) (/ (+ 20 blur-radius) 2) string 0 TRUE font-size PIXELS font)))
  41.  
  42.     (set! text-mask (car (gimp-layer-create-mask text-layer ADD-ALPHA-MASK)))
  43.     (gimp-layer-add-mask text-layer text-mask)
  44.  
  45.     (gimp-selection-layer-alpha text-layer)
  46.     (gimp-context-set-background (list grey grey grey))
  47.     (gimp-edit-fill text-mask BACKGROUND-FILL)
  48.     (gimp-selection-none img)
  49.     (if (> blur-radius 0)
  50.         (plug-in-gauss-iir 1 img text-mask blur-radius 1 1)
  51.     )
  52.  
  53.     (plug-in-newsprint 1 img text-mask cell-size 0 0 45.0 3 45.0 0 45.0 0 45.0 0 3)
  54.  
  55.     (gimp-edit-fill text-layer FOREGROUND-FILL)
  56.     (gimp-layer-remove-mask text-layer MASK-APPLY)
  57.  
  58.     (gimp-image-undo-enable img)
  59.     (gimp-display-new img)
  60.  
  61.     (gimp-context-pop)))
  62.  
  63. (script-fu-register "script-fu-newsprint-text"
  64.             _"Newsprint Text..."
  65.             "Apply a screen to text"
  66.             "Austin Donnelly"
  67.             "Austin Donnelly"
  68.             "1998"
  69.             ""
  70.             SF-STRING     _"Text"               "Newsprint"
  71.             SF-FONT       _"Font"               "Sans"
  72.             SF-ADJUSTMENT _"Font size (pixels)" '(100 2 1000 1 10 0 1)
  73.             SF-ADJUSTMENT _"Cell size (pixels)" '(7 1 100 1 10 0 1)
  74.             SF-ADJUSTMENT _"Density (%)"        '(60 0 100 1 10 0 0)
  75.             SF-ADJUSTMENT _"Blur radius"        '(0 0 100 1 5 0 0)
  76.                     SF-COLOR      _"Text color"         '(0 0 0)
  77.             SF-COLOR      _"Background color"   '(255 255 255))
  78.  
  79. (script-fu-menu-register "script-fu-newsprint-text"
  80.              _"<Toolbox>/Xtns/Script-Fu/Logos")
  81.